import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { viteMockServe } from 'vite-plugin-mock';
import eslintPlugin from 'vite-plugin-eslint';

// https://vitejs.dev/config/
export default defineConfig({
	base: '/neuedu-web/',
	plugins: [
		vue(),
		// viteMockServe({
		//   mockPath: "./src/api/mock/"
		// }),
		eslintPlugin({
			include: ['src/**/*.ts', 'src/**/*.vue', 'src/*.ts', 'src/*.vue'],
		}),
	],
	resolve: {
		alias: {
			'@': resolve(__dirname, 'src'),
			components: resolve(__dirname, 'src/components'),
		},
		extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.vue', '.mjs'],
	},
	server: {
		// 服务器主机名，如果允许外部访问，可设置为 "0.0.0.0"
		host: '0.0.0.0',
		cors: true,
		// 代理跨域（mock 不需要配置跨域，直接能访问，这里只是个示例）
		proxy: {
			'/api': {
				target: 'http://127.0.0.1:9090',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, '/sys-api'),
			},
		},
	},
});
